package org.luxor.commons.playwright.client;

import org.luxor.commons.playwright.component.command.PlaywrightCommand;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

/**
 * playwright核心服务接口
 *
 * @author Mr.yan  @date 2022/6/10
 */
public interface PlaywrightClient {

    /**
     * 执行浏览器驱动指令
     *
     * @param command 驱动指令
     * @return T
     */
    <T> T execute(PlaywrightCommand<T> command);

    /**
     * 异步执行浏览器驱动指令
     *
     * @param command 驱动指令
     * @return T
     * @throws ExecutionException   获取执行结果失败时，会抛出该异常
     * @throws InterruptedException 线程被中断时，会抛出该异常
     */
    <T> Future<T> executeAsync(PlaywrightCommand<T> command) throws ExecutionException, InterruptedException;

}
